package leetcode.weekly.week305;

import java.util.HashSet;
import java.util.Set;

//Solution1Test
public class Solution1 {

	public int arithmeticTriplets(int[] nums, int diff) {
		int ans = 0;
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < nums.length; i++) {
			int num = nums[i];
			if (i >= 2 && set.contains(num - diff) && set.contains(num - diff * 2)) {
				ans++;
			}
			set.add(num);
		}
		return ans;
	}
}
